import VueRouter from 'vue-router'
import login from './pages/login.vue'
import test_index from './pages/indexSubPages/test_index.vue'
import test_index2 from './pages/indexSubPages/test_index2.vue'
import index from './pages/index.vue'

import create_excel from './pages/create_excel.vue'
import my_excels from './pages/indexSubPages/my_excels.vue'
import edit_excel from './pages/edit_excel.vue'
import department_excel from './pages/department_excel.vue'
import sub_department_excels from './pages/sub_department_excels.vue'
import OtherExcels from './pages/OtherExcels.vue'
import my_excels_show from './pages/my_excels_show.vue'

import index_admin from './pages/index_admin.vue'
import users from './pages/indexAdminPages/users.vue'
import add_user from './pages/indexAdminPages/add_user.vue'
// 3. 创建路由对象//获取原型对象上的push函数
// const originalPush =  VueRouter.prototype.push
// //修改原型对象中的push方法
// VueRouter.prototype.push = function push(location) {
//    return originalPush.call(this, location).catch(err => err)
// }

var router = new VueRouter(
  {
    routes: [
      {path:'/', redirect:'/login'},
      // {path:'/index', redirect:'/index/other1'},
      {path:'/login',component:login},
      {
        path:'/index',
        component:index,
        children: [
          {
            path:'test',
            component:test_index
          },
          {
            path:'test2',
            component:test_index2
          },
          {
            path:'my_excels',
            component:my_excels
          },
          {
            path:'other_excels',
            component:OtherExcels
          },
          {
            path:'sub_department_excels',
            component:sub_department_excels
          },

        ]          
      },
      {
        path:'/index_admin',
        component:index_admin,
        children: [
          {
            path:'users',
            component:users
          },
          {
            path:'add_big_user',
            component:add_user
          },
        ]          
      },
      {
        path:'/my_excels_show',
        component:my_excels_show
      },
      {
        path:'/create',
        component:create_excel           
      },
      {
        path:'/edit',
        component:edit_excel        
      },
      {
        path:'/department_excel',
        component: department_excel     
      }
    ]}
)

// 把路由对象暴露出去
export default router